using System;
using System.Collections.Generic;
using System.Text;

using Db4o.Framework.Interfaces;

namespace SampleBusiness
{
    public class RaceTeam : ManagedType
    {
        char NEWLINE = '\n';
        private string name;
        private List<Pilot> pilots;
        private int points;

        public int Points
        {
            get { return points; }
            set { points = value; }
        }

        public List<Pilot> Pilots
        {
            get { return pilots; }
            set { pilots = value; }
        }
        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        public RaceTeam(string name, int points, IList<Pilot> pilots)
        {
            Name = name;
            Pilots = (List<Pilot>)pilots;
            Points = points;
        }
        public RaceTeam(string name, int points) : this(name,points,new List<Pilot>())
        {
            
        }
        public RaceTeam(): this(String.Empty,0,new List<Pilot>())
        {
            
        }
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendFormat("[{0}] {1} - {2}pts", Id, Name,Points);
         
            return builder.ToString();
        }
        public string ListPilots()
        {
            StringBuilder builder = new StringBuilder();
            foreach (Pilot pilot in Pilots)
                builder.AppendFormat("\t - {0} {1}", pilot, NEWLINE);
            return builder.ToString();
        }
    }
}
